Summary

While it is certainly possible to further enhance and refine MiniEdit, you have already learned how to harness several powerful capabilities of Visual Basic.  

WHAT MINIEDIT CAN AND CANNOT DO

With MiniEdit, a user can create a text file and save it to a filename.  A user can also open an existing text file, edit, and save the changes.  

MiniEdit has a number of shortcomings, however.  For example, commands in MiniEdit are always enabled, even when the choice might be inappropriate.  In professional Windows programs, a menu command is grayed, or dimmed, whenever it is not meaningful for a user to choose it.

MiniEdit doesn't remember filenames.  The user enters a filename to open a file and enters the filename again to save the file.  MiniEdit also lets you exit the program without asking you to save your work.

All of these shortcomings could be eliminated if MiniEdit had a way of preserving information from event to event.  If the filename entered in the Open event could be saved for use in the Save As event, MiniEdit could include the old filename as a default in the InputBox function.

At this point, all variables and their values come into existence when an event occurs.  They cease to exist when the program exits the event procedure.  As you will see in the future, there is indeed a way to make values persist for longer than the handling of single events.

DEFENSIVE PROGRAMMING

Because MiniEdit does not do any error checking, you can easily make the program terminate with a run-time error.  Up to this point, all the programs you have built have functioned in their own little world, not touching data outside themselves.  As soon as a program has to interact with the file system, though, you must expect the unexpected.

Think of the problems that could occur.  A user may type in a bad filename, for example, or the name of a nonexistent file.  The file the user is trying to open cannot be opened, either because someone else on your computer's network has it open exclusively, or because of insufficient memory.  The user can't save a file because there is not enough space left on the disk.  MiniEdit can detect only some of these errors.  You need to learn more about error handling before you can write code to detect all of these errors.

Still, as you build programs, you should anticipate that operations may fail.  You should think about ways to have the program recover gracefully if a problem occurs.  Instead of terminating with a run-time error, the program should alert the user and then continue.  Writing code that guards against error and prevents them from occurring is called "defensive programming."

